// 本文件由自动工具 proto.py 自动生成，请勿修改
// filename test_csbuf.lua
// package test

// require "test1_csbuf"

test = test or {}

-- message Test
test.Test = {
	protoid = 1001,
	t1: number = 0;
	t_2: number = 0;
	t3_: string = "";
	t4: number = [],
}

function test.Test:Marshal(writer)
	writer:setUint8(this.t1, 1)
	writer:setUint32(this.t_2, 2)
	writer:setString(this.t3_, 3)
	writer:setArray(#this.t4, 4)
	for (let v of this.t4) {
		writer:setUint32(v, 0)
	}
end

function test.Test:Unmarshal(reader)
	this.t1 = reader:getUint8(1)
	this.t_2 = reader:getUint32(2)
	this.t3_ = reader:getString(3)
	local count = reader:getArray(4)
	for (let i=1; i < count; i++) {
		this.t4.push(reader:getUint32(0)))
	}
end

function test.Test:create()
	return clone(test.Test)
end

-- message t2
test.t2 = {
	protoid = 1002,
	t1: number = 0;
	t3: number = 0;
}

function test.t2:Marshal(writer)
	writer:setUint8(this.t1, 1)
	writer:setInt16(this.t3, 2)
end

function test.t2:Unmarshal(reader)
	this.t1 = reader:getUint8(1)
	this.t3 = reader:getInt16(2)
end

function test.t2:create()
	return clone(test.t2)
end

return test
